package com.ridu.project.beshid.controller.api;

import com.ridu.project.beshid.api.GeneralResponse;
import com.ridu.project.beshid.controller.BaseController;
import com.ridu.project.beshid.entity.UserEntity;
import com.ridu.project.beshid.repository.UserRepository;
import com.ridu.project.beshid.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Administrator on 2017/2/13.
 */
@Controller
@RequestMapping(value = "/api/category",produces = "application/json")
@Slf4j
public class CategoryApiController extends BaseController {

    @Autowired
    private CategoryService service;
    @Autowired
    private UserRepository userRepository;

    @RequestMapping(value = "getAll")
    @ResponseBody
    public GeneralResponse getAll(@RequestParam String token){
        UserEntity user = userRepository.findOneByToken(token);
        if(user != null && StringUtils.isNotBlank(user.getUsername())){
        } else {
            return GeneralResponse.error("请重新登陆");
        }
        return service.findAll();
    }

}

